<template>
  <div>
    <h2>v-for指令</h2>
    <ul>
      <li v-for="(item, index) in list" :key="item.id">
        <input type="checkbox">
        {{ index + 1 }} -- {{ item.id }} -- {{ item.name }} -- {{ item.nickname }}
        <button @click="del(item.id)">删除</button>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [
        { id: 200, name: '宋江', nickname: '及时雨' },
        { id: 400, name: '吴用', nickname: '智多星' },
        { id: 528, name: '林冲', nickname: '豹子头' },
        { id: 529, name: '林冲', nickname: '豹子头' },
        { id: 600, name: '林冲', nickname: '豹子头' },
        { id: 700, name: '林冲', nickname: '豹子头' },
        { id: 828, name: '林冲', nickname: '豹子头' },
      ]
    }
  },
  methods: {
    del (id) {
      // console.log(id) // 400
      this.list = this.list.filter(item => {
        return item.id != id
      })
    }
  }
}
</script>

<style>

</style>